include ../components/contact
block style
    link(rel='stylesheet', href=__CSS_PATH__ + '/form.css')
.work-create
    .work-form-control
        label.work-control-label(for='name') 节点名称:
        input#name.work-form-control(type='text' value=nodeInfo.name)
    .work-form-control
        label.work-control-label(for='approver') 审批人配置:
        input#approver.form-control(type='text' readonly value=nodeInfo.approveUsersId)
        i.icon.icon-add#addUser
    .work-form-control
        label.work-control-label 执行规则:
        label.text-label
            if(nodeInfo.executeCond  === 'ALL')
                input.form-control(type='radio' checked name='rule' value="ALL")
            else
                input.form-control(type='radio'  name='rule' value="ALL")
            span 所有人审批即通过
        label.text-label
            if(nodeInfo.executeCond === 'ONE')
                input.form-control(type='radio' checked  name='rule' value="ONE")
            else
                input.form-control(type='radio' name='rule' value="ONE")
            span 任意一人审批即通过
    .work-form-control
        label.work-control-label 节点跳转设置:
        label.text-label
            if(nodeInfo.forwardCond   === 'Y')
                input.form-control(type='radio' checked name='forwardCond' value="Y")
            else
                input.form-control(type='radio'  name='forwardCond' value="Y")
            span 允许指定跳转节点
        label.text-label
            if(nodeInfo.forwardCond === 'N')
                input.form-control(type='radio' checked  name='forwardCond' value="N")
            else
                input.form-control(type='radio' name='forwardCond' value="N")
            span 不允许指定跳转节点
    .work-form-control
        label.work-control-label 执行时间配置:
        label.text-label
            if(nodeInfo.executeHours === 0)
                input.form-control(type='radio' checked  name='executeTime' value='N')
            else
                input.form-control(type='radio'  name='executeTime' value='N')
            span 不需要配置时间
        label.text-label
            if(nodeInfo.executeHours !== 0)
                input.form-control(type='radio' checked name='executeTime' value='Y')
            else
                input.form-control(type='radio' name='executeTime' value='Y')
            span 需要配置时间
        .text-vice
            |请在
            input#executeTimeNum.fixed-width-input(type='tel' name='executeTimeNum' value=nodeInfo.executeHours)
            |小时内完成审批
        input#nodeId(type="hidden" value=nodeInfo.id)
    if(!isRead)
        .work-form-control
            label.work-control-label 节点功能配置:
            button.work-btn.work-btn-default.work-btn-sm(type='button') 节点功能配置
        .work-form-control.btn-wrapper.margin-top-20(style="justify-content: center;")
            button#saveNode.work-btn.work-btn-default.work-btn-sm(type='button') 保存
            button.work-btn.work-btn-default.work-btn-sm(type='button' style='margin-left:20px' onclick="$('#attributeModal').modal('hide');") 关闭
if(!isRead)
    #modal(style='display:none')
        +ContactBook
    #mask(style='display:none')
block script
    script(type="text/javascript" src=__JS_PATH__ + "/common.js")
    script(type="text/javascript" src=__JS_PATH__ + "/workflow/workflow_create.js")
    script(type="text/javascript").
        $('#saveNode').click(function () {
            var data = {};
            data.name = $('#name').val();
            data.approveUsersId = $('#choosePersonId').val();
            data.executeCond = $('input[name="rule"]').filter(':checked').val();
            data.forwardCond = $('input[name="forwardCond"]').filter(':checked').val();
            data.executeHours = $('#executeTimeNum').val();
            data.defineId = flowID;
            data.id = $('#nodeId').val();

            var checkInfo = checkValue(data);
            console.log(data);

            if (checkInfo) {
                layerAlert(checkInfo);
                return;
            }
            // 开始提交
            $.post('/workflow/node_save', data, function (results) {
                if (results.code == 1) {
                    layerAlert("保存节点配置成功");
                    $('#window'+data.id).find(".process-name").text(data.name);
                    //关闭遮罩层
                    $('#attributeModal').modal('hide');
                }else{
                    layerAlert(results.msg);
                }
            }, 'json');
        })